import 'package:flutter/material.dart';
import 'package:fluttertoast/fluttertoast.dart';
import 'package:stock_check/common/utils/CommonUtils.dart';

class InputDialog extends StatefulWidget {
  const InputDialog({Key key}) : super(key: key);
  @override
  _InputDialogState createState() => _InputDialogState();
}

class _InputDialogState extends State<InputDialog> {
  TextEditingController controller = new TextEditingController();


  @override
  Widget build(BuildContext context) {
    return Material(
        type: MaterialType.transparency,
        child: GestureDetector(
          onTap: (){
            Navigator.pop(context);
          },
          child: Center(
            child: Container(
              width: CommonUtils.getScreenWidth(context)-20,
              height: 190,
              child: Card(
                  child: Column(
                    crossAxisAlignment: CrossAxisAlignment.start,
                    children: <Widget>[
                      Container(
                          padding: EdgeInsets.all(5.0),
                          child: Column(
                            children: <Widget>[
                              TextField(
                                controller:controller,
                                maxLines: 4,
                                onChanged: (v){

                                },
                                decoration: InputDecoration(
                                    border: OutlineInputBorder(
                                        borderSide: BorderSide(
                                            color: Colors.blue
                                        )
                                    ),
                                    hintText: '请输入巡检总结...'
                                ),
                              ),
                              Row(
                                mainAxisAlignment: MainAxisAlignment.end,
                                children: <Widget>[
                                  RaisedButton(
                                    onPressed: (){
                                      Navigator.pop(context,null);
                                    },
                                    shape: RoundedRectangleBorder(
                                        borderRadius: BorderRadius.only(
                                            topLeft:Radius.circular(20.0),
                                            bottomLeft: Radius.circular(20.0)
                                        )
                                    ),
                                    elevation: 1.0,
                                    textColor: Colors.white,
                                    color: Colors.blueGrey,
                                    child: Text("取消"),
                                  ),
                                  RaisedButton(
                                    onPressed: (){
                                      if(controller.text.isEmpty){
                                        Fluttertoast.showToast(
                                            msg: '请输入评估总结!',
                                            gravity: ToastGravity.CENTER
                                        );
                                        return;
                                      }
                                      Navigator.pop(context,controller.text);
                                    },
                                    shape: RoundedRectangleBorder(
                                        borderRadius: BorderRadius.only(
                                            topRight:Radius.circular(20.0),
                                            bottomRight: Radius.circular(20.0)
                                        )
                                    ),
                                    elevation: 1.0,
                                    textColor: Colors.white,
                                    color: Theme.of(context).accentColor,
                                    child: Text("确认"),
                                  ),
                                ],
                              )
                            ],
                          )
                      ),
                    ],
                  )
              ),
            ),
          ),
        )
    );
  }
}
